﻿using Aspose.Hook;
using NUnit.Framework;

namespace WordStudy20250123.T001
{
    [TestFixture]
    public class WordTest04
    {
        [SetUp]
        public void Setup()
        {
            HookManager.ShowHookDetails(true);
            HookManager.StartHook();
        }

        [Test]
        public void WordMerge()
        {
            var inputFiles = new List<string>
            {
                @"D:\data\WordStudy20250123\WordTest04\doc1.docx",
                @"D:\data\WordStudy20250123\WordTest04\doc2.docx",
                @"D:\data\WordStudy20250123\WordTest04\doc3.docx",
                @"D:\data\WordStudy20250123\WordTest04\doc4.docx",
            };
            var outputFile = @"D:\data\WordStudy20250123\WordTest04\merged.docx";

            WordHelper.MergeDocuments(inputFiles, outputFile);
            Console.WriteLine("文档已合并并保存到 " + outputFile);
        }

        [Test]
        public void WordAppend()
        {
            var sourceFile = @"D:\data\WordStudy20250123\WordTest04\source.docx";
            var destinationFile = @"D:\data\WordStudy20250123\WordTest04\destination.docx";

            WordHelper.AppendDocument(sourceFile, destinationFile);
            Console.WriteLine("文档已追加并保存到 " + destinationFile);
        }

        [Test]
        public void WordBookMark()
        {
            var templateFile = @"D:\data\WordStudy20250123\WordTest04\bookMarkTemplate.docx";
            var outputFile = @"D:\data\WordStudy20250123\WordTest04\bookMarkOutput.docx";
            var bookmarkTextPairs = new Dictionary<string, string>
            {
                { "GoodsName", "储能变流器" },
                { "GoodsCode", "TE186K-HV" },
                { "CompanyName", "特变电工新疆新能源股份有限公司" },
                { "TestType", "委托检测" },
            };

            WordHelper.InsertTextAtBookmarks(templateFile, outputFile, bookmarkTextPairs);
            Console.WriteLine("文档已保存到 " + outputFile);
        }

        [Test]
        public void SubScript()
        {
            var filePath = @"D:\data\WordStudy20250123\WordTest04\subscript_template.docx";
            var outputFilePath = @"D:\data\WordStudy20250123\WordTest04\subscript_document.docx";
            var text = "M";
            var subscriptText = "2";
            var superscriptText = "1";

            WordHelper.InsertSubscriptAndSuperscript(filePath, text, subscriptText, superscriptText, outputFilePath);
            Console.WriteLine("文档已保存到 " + outputFilePath);
        }
    }
}
